﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Automation.Peers;
using System.Windows.Automation.Provider;
using System.Windows.Browser;
using System.Windows.Controls;

namespace Noria.Web.MyMSDN.Checksum
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            //HtmlPage.RegisterScriptableObject("Hash", this);
        }

        //[ScriptableMember]
        //public void BeginChecksum()
        //{
        //    IInvokeProvider peer = new ButtonAutomationPeer(FakeBtn);
        //    peer.Invoke();
        //}

        private void FakeBtn_OnClick(object sender, RoutedEventArgs e)
        {
            var ofd = new OpenFileDialog();
            ofd.Multiselect = false;
            ofd.Filter = "Any File|*.*";
            if (ofd.ShowDialog().Value)
            {
                new HashCalculator(ofd.File, FakeBtn).Calc();

                //op.Target = dlg.File;
                //op.CalculateHash();
                //MessageBox.Show(ofd.File.Name, "Silverlight", MessageBoxButton.OK);

                //var uri = HtmlPage.Document.DocumentUri;
                //var path = uri.Scheme + "://" + uri.Host + ":" + uri.Port;
                //var request = WebRequest.CreateHttp(path + "/mm/svc/locale.ashx");
                //IAsyncResult result = request.BeginGetResponse(ChecksumCallback, request);

            }
        }

       
    }
}
